package com.xblibo.xruth.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.xblibo.xruth.common.BaseEntity;

/**   
 * @Title: Fuction.java
 * @Package xb.core.mode.role
 * @Description: TODO(功能，基础表，用于权限控制)
 * @author libo  
 * @date Dec 28, 2010 12:37:28 PM
 * @version V1.0   
 */
@Entity
@Table(name="function")
public class Function extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 功能名称
	 */
	@Column(name="name",length=25)
	private String name;
	
	/**
	 * 模块名称英文
	 */
	@Column(name="short_name",length=25)
	private String shortName;
	
	/**
	 * 功能对应的uri
	 */
	@Column(name="uri",length=50)
	private String uri;
	
	/**
	 * 功能所属的模块ID
	 */
	/* cascade表示级联。CascadeType.REFRESH级联刷新   
	 * optional表示该对象可有可无，它的值为true表示该外键可以为null，它的值为false表示该外键为not null   
	 * JoinColumn表示外键的列 
	 */
	@ManyToOne
	@JoinColumn(name="module_id", nullable=true, insertable = true, updatable = true) 
	private Module module;
	
	/**
	 * 是否是默认的,0为false,1为ture
	 */
	@Column(name="is_defual")
	private Boolean isDefual;
	
	/**
	 * 点击模块时：是否是默认打开的,0为false,1为ture
	 */
	@Column(name="is_defualOpen")
	private Boolean isDefualOpen;
	
	@Column(name="is_menu")
	private Boolean isMenu;
	
	 @ManyToMany(mappedBy = "functions", targetEntity = Role.class, fetch = FetchType.EAGER)  
	 private Set<Role> roles;  

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}
	

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public Boolean getIsDefual() {
		return isDefual;
	}

	public void setIsDefual(Boolean isDefual) {
		this.isDefual = isDefual;
	}

	public Boolean getIsDefualOpen() {
		return isDefualOpen;
	}

	public void setIsDefualOpen(Boolean isDefualOpen) {
		this.isDefualOpen = isDefualOpen;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public Boolean getIsMenu() {
		return isMenu;
	}

	public void setIsMenu(Boolean isMenu) {
		this.isMenu = isMenu;
	}
	
	
}
